<?php
class Admin_Model_ContentModule extends Zend_Db_Table{
	protected $_name = 'content_module';
	protected $_primary = 'module_id';
	/* Link tham khao : http://framework.zend.com/manual/en/zend.db.table.html */
	
	public function selectModuleByCode($module_code)
	{
		$client = new Zend_Rest_Client(HTTP_SERVICE);
		$return = $client->restGet("/contentmodule/route/selectModuleByCode/module_code/".$module_code);
		$return = json_decode(json_encode((array) simplexml_load_string($return->getBody())),1);
		
		for ($i=0;$i <count($return);$i++)
				$data[$i] = $return['row_'.$i];	
		return $data;
	}
	/*
	public function selectModuleBySortOrder($sort_order)
	{
		$select = $this->select();
		$select->from('content_module');
		$select->setIntegrityCheck(false);
		$select->where('sort_order = ?', $sort_order);
		$arr = $this->fetchAll($select);
		return $arr;
	}	
		*/
	public function deleteModuleByCode($code)
	{// co dung
		$client = new Zend_Rest_Client(HTTP_SERVICE);
		$return = $client->restDelete("/contentmodule/route/deleteModuleByCode/code/".$code);
		
		return $return->getBody();
	}
	
	public function insertModule($data)
	{// co dung
		$data['route'] = "insertModule";
		$client = new Zend_Rest_Client(HTTP_SERVICE);
		$return = $client->restPost("/contentmodule", $data);
		return $return->getBody();
	}
}